package com.zhufei.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.zhufei.entity.UserInfo;

public class Bbscs_UserdetailDAO extends DBCon{
	private static String TABLE = "bbscs_userdetail";
	private static String ID = "ID";
	private static String SEX = "sex";
	/**
	 * 根据id返回性别
	 * @param id id
	 * @return 1表示男，2表示女，0表示性别不明！
	 */
	public static int getSex(String id){
		DBCon con = new DBCon();
		try {
			Statement statement = con.getStatement();
			String sql = "select "+SEX+" from "+TABLE+" where "+ID+"='"+id+"'";
			ResultSet rs = statement.executeQuery(sql);
			if(rs.next()){
				int s = rs.getInt(SEX);
				rs.close();
				return s;
				
			}else{
				rs.close();
				return 0;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			con.closeDB();
		}
		return 0;
	}
}
